<template>
  <div class="container">
    <el-form ref="dataForm" :model="conModel" label-width="72px" size="mini" class="search_content">
      <el-row :gutter="24">
        <!-- <el-col :span="4" class="common_input">
          <el-form-item label="通信编号:" prop="CommNo">
            <el-input v-model="conModel.CommNo" clearable placeholder="请输入通信编号" @keyup.enter.native="getList('search')" />
          </el-form-item>
        </el-col> -->
        <el-col :span="4" class="common_input">
          <el-form-item label="客户名称:">
            <el-input v-model="conModel.CustomerName" clearable placeholder="请输入客户名称" @keyup.enter.native="getList('search')" />
          </el-form-item>
        </el-col>
        <el-col :span="4" class="common_input">
          <el-form-item label="计量点:" prop="Address">
            <el-input v-model="conModel.Address" clearable placeholder="请输入计量点" @keyup.enter.native="getList('search')" />
          </el-form-item>
        </el-col>
        <el-col :span="4" class="common_picker">
          <el-form-item label="开始时间:">
            <el-date-picker
              v-model="conModel.StartTime"
              type="datetime"
              format="yyyy-MM-dd HH:mm"
              alue-format="yyyy-MM-dd HH:mm"
              placeholder="请选择开始时间"
              size="mini"
              class="search_common_picker"
            />
          </el-form-item>
        </el-col>
        <el-col :span="4" class="common_picker">
          <el-form-item label="结束时间:">
            <el-date-picker
              v-model="conModel.EndTime"
              type="datetime"
              format="yyyy-MM-dd HH:mm"
              alue-format="yyyy-MM-dd HH:mm"
              placeholder="请选择结束时间"
              size="mini"
              class="search_common_picker"
            />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="4" class="common_input">
          <el-form-item label="支付方式:" prop="PayWayID">
            <el-select v-model="conModel.PayWayID" clearable placeholder="请选择支付方式">
              <el-option
                v-for="item in listPayWay"
                :key="item.PayWayId"
                :label="item.PayWayName"
                :value="item.PayWayId"
              />
            </el-select>
          </el-form-item>
        </el-col> -->
        <el-col :span="4" class="common_input">
          <el-form-item label="结算状态:" prop="OperConfirmStateId">
            <el-select v-model="conModel.OperConfirmStateId" clearable placeholder="请选择结算状态">
              <el-option key="0" label="全部" value="" />
              <el-option key="1" label="待确认" value="1" />
              <el-option key="2" label="已确认" value="2" />
              <!-- <el-option key="3" label="有异议" value="3" /> -->
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4" class="common_picker">
          <el-form-item label="账期:">
            <el-date-picker
              v-model="conModel.AccPeriod"
              type="month"
              format="yyyy-MM"
              alue-format="yyyy-MM"
              placeholder="请选择账期"
              size="mini"
              class="search_common_picker"
            />
          </el-form-item>
        </el-col>
        <el-col :span="1" class="common_query">
          <el-button size="mini" @click="getList('search')">
            查询
          </el-button>
        </el-col>
        <el-col :span="1" :offset="1" class="common_query">
          <el-button size="mini" @click="RowUpdate()">
            一键确认
          </el-button>
        </el-col>
        <div class="common_right_btn common_query">
          <el-col :span="1">
            <el-button @click="exportReport()"><span>导出</span></el-button>
          </el-col>
        </div>
      </el-row>
    </el-form>
    <p v-show="statisticShow" class="statistic">
      本次用气量合计：{{ statistic.SumThisUse }},气量合计1: {{ statistic.SumThisUse1 }},气量合计2: {{ statistic.SumThisUse2 }},
    </p>
    <p v-show="statisticShow" class="statistic">
      结算金额合计：{{ statistic.SumBalanceMoney }},结算金额合计1: {{ statistic.SumBalanceMoney1 }},结算金额合计1: {{ statistic.SumBalanceMoney2 }},实付金额合计：{{ statistic.SumActualPayMoney }}
    </p>
    <div class="table_content">
      <el-table
        v-loading="listLoading"
        :data="list"
        fit
        style="width: 100%;"
        :stripe="true"
        @select="mySelect"
        @select-all="mySelect"
        >
        <el-table-column
          type="selection"
        />
        <el-table-column align="center" label="本次结算时间" width="160px">
          <template slot-scope="scope">
            {{ scope.row.BalanceTime | dateFormat}}
          </template>
        </el-table-column>
        <el-table-column align="center" label="铭牌号" width="150px">
          <template slot-scope="scope">
            {{ scope.row.BarCode }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="客户名称" width="130px">
          <template slot-scope="scope">
            {{ scope.row.CustomerName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="计量点" width="200px">
          <template slot-scope="scope">
            {{ scope.row.Address }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="结算类型">
          <template slot-scope="scope">
            {{ scope.row.BalanceTypeName }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="供气类型" width="100px">
          <template slot-scope="scope">
            {{ DivideType(scope.row.DivideType) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="上次结算时间" width="160px">
          <template slot-scope="scope">
            {{ scope.row.LastBalanceTime | dateFormat}}
          </template>
        </el-table-column>
        <el-table-column align="center" label="上次抄表读数(总)" width="130px">
          <template slot-scope="scope">
            {{ scope.row.LastRead }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="本次抄表读数(总)" width="130px">
          <template slot-scope="scope">
            {{ scope.row.ThisRead }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="本次用气量(总)" width="130px">
          <template slot-scope="scope">
            {{ scope.row.ThisUse }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="管输气用量" width="120px">
          <template slot-scope="scope">
            {{ scope.row.ThisUse1 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="代输气用量" width="120px">
          <template slot-scope="scope">
            {{ scope.row.ThisUse2 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="本期总金额" width="120px">
          <template slot-scope="scope">
            {{ scope.row.BalanceMoneyTotal }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="管输气结算金额" width="120px">
          <template slot-scope="scope">
            {{ scope.row.BalanceMoney1 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="代输气结算金额" width="120px">
          <template slot-scope="scope">
            {{ scope.row.BalanceMoney2 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="代输费" width="120px">
          <template slot-scope="scope">
            {{ scope.row.AgentGasMoney }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="结算状态">
          <template slot-scope="scope">
            {{ OperConfirmState(scope.row.OperConfirmStateId) }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="160px">
          <template slot-scope="{row}">
            <span class="common_operation" @click="detailsPopup(row)">详情</span>
            <span v-show="row.OperConfirmStateId !== 2" class="common_operation" @click="UpdateBalanceFee(row)">确认</span>
            <span class="common_operation" v-show="row.OperConfirmStateId == 1" @click="UpdateBalanceFee(row,'no')">撤销</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="预览" width="200px">
          <template slot-scope="{row}">
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice1','preview')">缴费通知单</span>
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice2','preview')">代采缴费通知单</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="打印" width="200px">
          <template slot-scope="{row}">
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice1','print')">缴费通知单</span>
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice2','print')">代采缴费通知单</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="导出" width="200px">
          <template slot-scope="{row}">
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice1','pdf')">缴费通知单</span>
            <span class="common_operation" style="width: 200px" @click="ws_ajax_print(row,'PrepayBalanceInvoice2','pdf')">代采缴费通知单</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <pagination v-show="total>0" class="my_pagination" :total="total" :PageIndex.sync="Parameter.PageIndex" :PageSize.sync="Parameter.PageSize" @pagination="getList" />
    <el-dialog title="撤销" :visible.sync="dialogFormVisible" class="newel-dialog common_add_edit_popup_one">
      <div class="el-dialog__body">
        <el-form ref="dataForm" :rules="rules" :model="temp" class="demo-ruleForm common_popup" label-width="100px">
          <el-row :gutter="24">
            <el-col :span="15" :offset="4">
              <div class="grid-content bg-purple">
                <el-form-item label="撤销原因:" prop="OperConfirmReason">
                  <el-input v-model="temp.OperConfirmReason" clearable placeholder="请输入撤销原因" />
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
        <hr class="common_popup_border_bottom">
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="add_edit_btn cancel" @click="dialogFormVisible = false">
          取消
        </el-button>
        <el-button class="add_edit_btn determine" @click="updata()">
          确定
        </el-button>
      </div>
    </el-dialog>
    <!-- 确认 -->
    <el-dialog
      :visible.sync="dialogVisibleConfirm"
      class="common_delete_popup"
      :modal-append-to-body="false"
    >
      <div slot="title" class="header-title">
        <span class="title-age">提示</span>
      </div>
      <span class="delete_tips">是否确认?</span>
      <span slot="footer" class="dialog-footer">
        <el-button class="cancel" @click="dialogVisibleConfirm = false">取消</el-button>
        <el-button class="delete" @click="confirmReport()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 详情 -->
    <el-dialog title="结算记录详情" :visible.sync="dialogDetails" class="newel-dialog details_pupop balanceRecord_details common_details">
      <div class="el-dialog__body">
        <el-form ref="dataForm" :model="tempDetails" class="demo-ruleForm common_popup" label-width="180px">
          <div class="common_details_bg"></div>
          <el-row :gutter="24">
            <el-col :span="7" :offset="1">
              <div class="grid-content bg-purple">
                <el-form-item label="结算时间:">
                  <span> {{ tempDetails.BalanceTime | dateFormat }} </span>
                </el-form-item>
                <el-form-item label="上次结算时间:">
                  <span> {{ tempDetails.LastBalanceTime | dateFormat }} </span>
                </el-form-item>
                <el-form-item label="客户编号:">
                  <span> {{ tempDetails.CustomerNo }} </span>
                </el-form-item>
                <el-form-item label="客户名称:">
                  <span> {{ tempDetails.CustomerName }} </span>
                </el-form-item>
                <el-form-item label="计量点:">
                  <span> {{ tempDetails.Address }} </span>
                </el-form-item>
                <el-form-item label="账期:">
                  <span> {{ tempDetails.AccPeriod }} </span>
                </el-form-item>
                <el-form-item label="结算类型:">
                  <span> {{ tempDetails.BalanceTypeName  }} </span>
                </el-form-item>
               
                <el-form-item label="价格名称:">
                  <span> {{ tempDetails.PriceName }} </span>
                </el-form-item>
                <el-form-item label="上次抄表读数(总):">
                  <span> {{ tempDetails.LastRead }} </span>
                </el-form-item>
                <el-form-item label="本次抄表读数(总):">
                  <span> {{ tempDetails.ThisRead }} </span>
                </el-form-item>
                <el-form-item label="本次用气量(总):">
                  <span> {{ tempDetails.ThisUse }} </span>
                </el-form-item>
                <el-form-item label="备注:">
                  <span> {{ tempDetails.Remark }} </span>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="7" :offset="1">
              <div class="grid-content bg-purple">
                <el-form-item label="收款操作员:">
                  <span> {{ tempDetails.PayOperator }} </span>
                </el-form-item>
                <el-form-item label="应缴金额:">
                  <span> {{ tempDetails.PayableMoney  }} </span>
                </el-form-item>
                <el-form-item label="应缴日期:">
                  <span> {{ tempDetails.PayableDate | dateFormat }} </span>
                </el-form-item>
                <el-form-item label="是否计算滞纳金:">
                  <span> {{ tempDetails.LateFeeEnable }} </span>
                </el-form-item>
                <el-form-item label="已滞纳天数:">
                  <span> {{ tempDetails.LateDays }} </span>
                </el-form-item>
                <el-form-item label="滞纳金:">
                  <span> {{ tempDetails.LateFee }} </span>
                </el-form-item>
                <el-form-item label="实付金额:">
                  <span> {{ tempDetails.ActualPayMoney }} </span>
                </el-form-item>
                <el-form-item label="收款时间:">
                  <span> {{ tempDetails.PayTime | dateFormat }} </span>
                </el-form-item>
                <el-form-item label="收费明细单流水号:">
                  <span> {{ tempDetails.ReceiptId }} </span>
                </el-form-item>
                <el-form-item label="预储值剩余金额:">
                  <span> {{ tempDetails.RemainMoney }} </span>
                </el-form-item>
                <el-form-item label="结算操作员:">
                  <span> {{ tempDetails.BalanceOperator }} </span>
                </el-form-item>
                <el-form-item label="支付方式:">
                  <span> {{ tempDetails.PayWayName }} </span>
                </el-form-item>
                <el-form-item label="支付状态:">
                  <span> {{ tempDetails.PayStateName }} </span>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="7" :offset="1">
              <div class="grid-content bg-purple">
                <el-form-item label="供气类型:">
                  <span> {{ DivideType(tempDetails.DivideType) }} </span>
                </el-form-item>
                <el-form-item label="定量:">
                  <span> {{ tempDetails.DivideVol }} </span>
                </el-form-item>
                <el-form-item label="比例:">
                  <span> {{ tempDetails.DivideRatio }} </span>
                </el-form-item>
                <el-form-item label="代输单价:">
                  <span> {{ tempDetails.AgentGasRate }} </span>
                </el-form-item>
                <el-form-item label="管输气:">
                  <span> {{ tempDetails.ThisUse1 }} </span>
                </el-form-item>
                <el-form-item label="代输气:">
                  <span> {{ tempDetails.ThisUse2 }} </span>
                </el-form-item>
                <el-form-item label="管输气价格区间:">
                  <span> {{ tempDetails.PriceLevel1 }} </span>
                </el-form-item>
                <el-form-item label="代输气价格区间:">
                  <span> {{ tempDetails.PriceLevel2 }} </span>
                </el-form-item>
                <el-form-item label="管输气价格:">
                  <span> {{ tempDetails.CurrentPrice1 }} </span>
                </el-form-item>
                <el-form-item label="代输气价格:">
                  <span> {{ tempDetails.CurrentPrice2 }} </span>
                </el-form-item>
                <el-form-item label="结算金额(总):">
                  <span> {{ tempDetails.BalanceMoneyTotal }} </span>
                </el-form-item>
                <el-form-item label="管输气结算金额:">
                  <span> {{ tempDetails.BalanceMoney1 }} </span>
                </el-form-item>
                <el-form-item label="代输气结算金额:">
                  <span> {{ tempDetails.BalanceMoney2 }} </span>
                </el-form-item>
                <el-form-item label="代输费:">
                  <span> {{ tempDetails.AgentGasMoney }} </span>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="20" :offset="1">
              <div class="grid-content bg-purple">
                <el-form-item label="操作员确认时间:">
                  <span>{{ tempDetails.OperConfirmTime | dateFormat }}</span>
                </el-form-item>
                <el-form-item label="操作员结算状态及原因:">
                  <span> {{ OperConfirmState(tempDetails.OperConfirmStateId) }} </span>
                  <span>{{ tempDetails.OperConfirmReason }}</span>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="20" :offset="1">
              <div class="grid-content bg-purple">
                <el-form-item label="燃气用户确认时间:">
                  <span>{{ tempDetails.CustConfirmTime | dateFormat }}</span>
                </el-form-item>
                <el-form-item label="燃气用户结算状态及原因:">
                  <span> {{ OperConfirmState(tempDetails.CustConfirmStateId) }} </span>
                  <span>{{ tempDetails.CustConfirmReason }}</span>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="add_edit_btn determine" @click="dialogDetails = false">
          返回
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { BalanceRecord, UpdateBalanceFee, GetPayWay, BalanceRecordStatistic, BalanceFeeExport } from '@/api/basics'
import { getToken } from '@/utils/auth'
import { webapp_ws_ajax_run } from "@/utils/grwebapp"
import moment from 'moment'

export default {
  name: 'BalanceRecord',
  components: {
    Pagination
  },
  data() {
    return {
      Parameter: {
        PageSize: 10,
        PageIndex: 1,
        OrderBy: 'PayTime',
        isDesc: true
      },
      temp: {
        OperConfirmReason: ''
      },
      conModel: {
        StartTime: moment(new Date()).format('YYYY-MM-01 00:00'),
        EndTime: moment(new Date()).format('YYYY-MM-DD 23:59'),
        CustomerName: '',
        CommNo: '',
        PayWayId: '',
        Address: '',
        OperConfirmStateId: '', // 结算状态
        AccPeriod: moment(new Date()).format('YYYY-MM'),
      },
      conModelCopy: {},
      listLoading: false,
      tempDetails: [],
      listPayWay: [], // 支付方式
      dialogDetails: false,
      dialogFormVisible: false,
      dialogVisibleConfirm: false, // 确认
      list: [],
      total: 0,
      BalanceFeeId: '',
      OperConfirmReason: null,
      statistic: [], // 数据统计
      statisticShow: false,
      batchRow: '',
      notifi: null,
      rules: {
        OperConfirmReason: [
          { required: true, message: '请输入不确认原因', trigger: 'change' }
        ]
      }
    }
  },
  created() {
    this.getList()
    this.GetPayWay()
  },
  methods: {
    exportReport() {
      let StartTime = null
      let EndTime = null
      let AccPeriod = null
      if (this.conModel.StartTime !== null) {
        StartTime = moment(this.conModel.StartTime).format('YYYY-MM-DD HH:mm')
      }
      if (this.conModel.EndTime !== null) {
        EndTime = moment(this.conModel.EndTime).format('YYYY-MM-DD HH:mm')
      }
      if (this.conModel.AccPeriod !== null) {
        AccPeriod = moment(this.conModel.StartTime).format('YYYYMM')
      }
      let json = {
        ...this.conModel,
        AccPeriod: AccPeriod,
        StartTime: StartTime,
        EndTime: EndTime,
        OperConfirmStateId: this.conModel.OperConfirmStateId == '' ? null : this.conModel.OperConfirmStateId
      }
      let time = moment().format('YYYYMMDDHHmmss')
      var str = JSON.stringify(json)
      var enc = window.btoa(str)
      var encode = encodeURI(enc)
      // /api/Reports/Export/BalanceFeeExport?p={queryparam}&token={token}
      let url = jsonData.urlContent
      let getUrl = url + '/api/Reports/Export/DownLoadTpl?templateCode=' + 'BalanceFeeExport' + '&token=' + getToken()
      let dataUrl = url + '/api/Reports/Export/BalanceFeeExport?p=' + encode + '&token=' + getToken()
      // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
      var args = {
        type: 'xls', // 
        showOptionDlg: true, // 如果不显示打印对话框而直接打印，将此行注释去掉即可
        report: getUrl,
        data: dataUrl,
        filename: '结算记录报表' + time,
      };
      webapp_ws_ajax_run(args)
    },
    ws_ajax_print(row,code,type) {
      let url = jsonData.urlContent
      let time = moment().format('YYYYMMDDHHmmss')
      let getUrl = url + '/api/Reports/Export/DownLoadTpl?templateCode=' + code + '&token=' + getToken()
      let dataUrl = url + '/api/Reports/Export/GetPrepayBalanceInvoiceData?BalanceFeeId=' + row.BalanceFeeId + '&token=' + getToken()
      // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
      var args = {
        type: type, // 改成 xls ,pdf变成导出, preview 预览
        showOptionDlg: true, // 如果不显示打印对话框而直接打印，将此行注释去掉即可
        report: getUrl,
        data: dataUrl,
        filename: row.CustomerName + time,
      };
      webapp_ws_ajax_run(args)
    },
    // 多选
    mySelect(selection, row) {
      const arr = []
      selection.map(it => {
        if(it.OperConfirmStateId !== 2) {
          arr.push(it.BalanceFeeId)
        }
      })
      this.batchRow = arr.join(',')
    },
    getList(init) {
      if (init === 'search') {
        this.Parameter.PageIndex = 1
        this.conModelCopy = {}
        this.conModelCopy.PayWayID = this.conModel.PayWayID
      }
      if (this.conModel.StartTime !== null && init === 'search') {
        this.conModelCopy.StartTime = moment(this.conModel.StartTime).format('YYYY-MM-DD HH:mm')
      }
      if (this.conModel.EndTime !== null && init === 'search') {
        this.conModelCopy.EndTime = moment(this.conModel.EndTime).format('YYYY-MM-DD HH:mm')
      }
      if (this.conModel.CommNo.trim() !== '' && init === 'search') {
        this.conModelCopy.CommNo = this.conModel.CommNo.trim()
      }
      if (this.conModel.CustomerName.trim() !== '' && init === 'search') {
        this.conModelCopy.CustomerName = this.conModel.CustomerName.trim()
      }
      if (this.conModel.Address.trim() !== '' && init === 'search') {
        this.conModelCopy.Address = this.conModel.Address.trim()
      }
      if (this.conModel.OperConfirmStateId.trim() !== '' && init === 'search') {
        this.conModelCopy.OperConfirmStateId = this.conModel.OperConfirmStateId.trim()
      }
      if (this.conModel.AccPeriod !== null && init === 'search') {
        this.conModelCopy.AccPeriod = moment(this.conModel.AccPeriod).format('YYYYMM')
      }
      this.listLoading = true
      var Parameter = {
        ...this.Parameter,
        ...this.conModelCopy
      }
      if (init === 'search') {
        BalanceRecordStatistic(Parameter).then(res => {
          this.statistic = res.Data
          this.statisticShow = true
        })
      }
      BalanceRecord(Parameter).then(res => {
        this.list = res.Data
        this.total = res.Total
        this.listLoading = false
      })
    },
    // 详情
    detailsPopup(row) {
      this.tempDetails = Object.assign({}, row)
      this.dialogDetails = true
    },
    // 一键确认
    RowUpdate() {
      if (this.batchRow === '') {
        this.$message({
          message: '请至少选择一个表记',
          type: 'error'
        })
        return
      }
      let Parameter = {
        BalanceFeeId: this.batchRow,
        OperConfirmStateId: 2,
        OperConfirmReason: ''
      }
      UpdateBalanceFee(Parameter).then(res => {
        if (res.State === 'success') {
          this.$message({
            message: '一键确认成功',
            type: 'success'
          })
          this.batchRow = ''
          this.getList()
        }
      })
    },
    // 操作确认撤销弹窗
    UpdateBalanceFee(row,state) {
      this.BalanceFeeId = row.BalanceFeeId
      if (state === 'no') {
        this.temp.OperConfirmReason = ''
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
        return
      } else {
        this.dialogVisibleConfirm = true
        this.OperConfirmReason = row.OperConfirmReason
      }
    },
    // 确认
    confirmReport() {
      let Parameter = {
        BalanceFeeId: this.BalanceFeeId,
        OperConfirmStateId: 2,
        OperConfirmReason: this.OperConfirmReason === null ? '': this.OperConfirmReason
      }
      UpdateBalanceFee(Parameter).then(res => {
        if (res.State === 'success') {
          this.$message({
            message: '确认成功',
            type: 'success'
          })
          this.getList()
          this.BalanceFeeId = ''
          this.OperConfirmReason = null
          this.dialogVisibleConfirm = false
        }
      })
    },
    // 撤回操作
    updata() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          let Parameter = {
            BalanceFeeId: this.BalanceFeeId,
            OperConfirmStateId: 3, // 撤回
            OperConfirmReason: this.temp.OperConfirmReason
          }
          UpdateBalanceFee(Parameter).then(res => {
            if (res.State === 'success') {
              this.$message({
                message: '确认成功',
                type: 'success'
              })
              this.dialogFormVisible = false
              this.getList()
            }
          })
        }
      })
    },
    // 支付方式
    GetPayWay() {
      var Parameter = {
        PageSize: 99999,
        PageIndex: 1,
        OrderBy: 'PayWayId',
        isDesc: true
      }
      GetPayWay(Parameter).then(res => {
        this.listPayWay = res.Data
      })
    },
    OperConfirmState(type) {
      switch(type) {
        case 1:
          return '待确认'
        case 2:
          return '已确认'
        case 3:
          return '有异议'
        case null:
          return '暂无状态'
      }
    },
    DivideType(type) {
      switch (type) {
        case 0:
          return '无代输气'
        case 1:
          return '定量代输'
        case 2:
          return '定比例代输'
        case null:
          return '暂无状态'
      }
    }
  }
}
</script>

